import React,{useState,useEffect} from 'react'

export default function App() {
  const [state,setState]=useState(0)
  useEffect(()=>{
    let timer = setInterval(()=>{
      setState(state+10)
    },500)
    return ()=>{
      console.log('清楚定时器')
      clearInterval(timer)
    }
  })
  return (
    <div>
      <h1>{state}</h1>
    </div>
  )
}
